//
//  SARequest.h
//  Sapling LearningMerchat
//
//  Created by Saman Kumara on 11/28/11.
//  Copyright (c) 2011 Saman Kumara. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>

#import "SWFile.h"
@class SWRequest;


@protocol SARequestDelegate <NSObject>
-(void)dataResponce:(NSMutableData *)data;
-(void)dataWithResponce:(SWRequest *)request;
-(void)failWithRequest:(SWRequest *)request;



@end

@class SWFile;
@interface SWRequest : NSObject{
    BOOL isCancel, showRoundedView;
    UIActivityIndicatorView *indicator;
}

@property(nonatomic, retain) id delegate;
@property(nonatomic, assign) int tagNo, statusCode;
@property(nonatomic, retain) NSMutableData *responseData;
@property(nonatomic, retain) NSError *error;
@property(nonatomic, assign) float timeOut;
@property(nonatomic, retain)  NSURLConnection *connection;
@property(nonatomic, retain) UIView *roundedView;
@property(nonatomic, retain) UIView *backgroundView;
@property(nonatomic, retain) id userObject;
@property(nonatomic, retain) NSMutableURLRequest *request;
@property(nonatomic, retain) NSHTTPURLResponse *response;
@property(nonatomic, retain) NSString *method;
@property(nonatomic, retain) NSString *customContentType;




-(void)sendPostWithURL:(NSURL*)url parameter:(NSString *)param delegate:(id)delegate;
-(void)sendPostWithURL:(NSURL*)url parameter:(NSString *)param delegate:(id)del parentView:(UIView *)parentView;
-(void)sendPostWithURL:(NSURL*)url parameter:(NSString *)param delegate:(id)del parentView:(UIView *)parentView data:(NSData *)img;
-(void)sendPostWithURL:(NSURL*)url parameter:(NSString *)param delegate:(id)del parentView:(UIView *)parentView dataArray:(NSMutableArray *)dataArray;

-(void)sendGetWithURL:(NSURL*)url parameter:(NSString *)param delegate:(id)del;
-(void)sendGetWithURL:(NSURL*)url parameter:(NSString *)param delegate:(id)del parentView:(UIView *)parentView;

-(void)cancelRequest;

-(NSString *)responseString;
@end
